package com.fengzhi.web.dao.ssh.impl;

import java.util.List;

import com.fengzhi.web.dao.core.impl.GenericDaoImpl;
import com.fengzhi.web.dao.ssh.IUserDao;
import com.fengzhi.web.entity.TbUser;

public class UserDaoImpl extends GenericDaoImpl<TbUser> implements IUserDao {

	@SuppressWarnings("unchecked")
	@Override
	public TbUser findUserByUsername(String username) {
		log.info("根据用户名获取用户对象！");

		String hql = "from TbUser where username = ? ";
		Object[] values = new Object[] { username };
		List<TbUser> userList = (List<TbUser>) getHibernateTemplate().find(hql, values);

		if (userList != null && !userList.isEmpty()) {
			return userList.get(0);
		}

		return null;
	}

	@Override
	public void addUser(TbUser user) {
		log.info("添加用户数据");
		save(user);
	}

}
